﻿
Public Class Form2
    Private _Modo As Integer
    Public Property Modo() As Integer
        Get
            Return _Modo
        End Get
        Set(ByVal value As Integer)
            _Modo = value
        End Set
    End Property

    Private _CustomerID As String
    Public Property CustomerID() As String
        Get
            Return _CustomerID
        End Get
        Set(ByVal value As String)
            _CustomerID = value
        End Set
    End Property

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim guardar As New localhost.wsCustomers
        If Modo = 3 Then
            guardar.Escribir(TextBox1.Text,
                             TextBox2.Text,
                             TextBox3.Text,
                             TextBox4.Text,
                             TextBox5.Text,
                             TextBox6.Text,
                             TextBox7.Text,
                             TextBox8.Text,
                             TextBox9.Text,
                             TextBox10.Text,
                             TextBox11.Text,
                             4)

        Else

            guardar.Escribir(TextBox1.Text,
                             TextBox2.Text,
                             TextBox3.Text,
                             TextBox4.Text,
                             TextBox5.Text,
                             TextBox6.Text,
                             TextBox7.Text,
                             TextBox8.Text,
                             TextBox9.Text,
                             TextBox10.Text,
                             TextBox11.Text,
                             2)

        End If
        Me.Close()
    End Sub

    Private Sub Form2_Activated(sender As Object, e As EventArgs) Handles Me.Activated
        If Modo = 3 Then
            Dim buscar As New localhost.wsCustomers
            Dim oCustomer As New localhost.beCustomers
            oCustomer = buscar.GetCustomerById(CustomerID)
            With oCustomer
                TextBox1.Text = .CustomerID
                TextBox2.Text = .CompanyName
                TextBox3.Text = .ContactName
                TextBox4.Text = .ContactTitle
                TextBox5.Text = .Address
                TextBox6.Text = .City
                TextBox7.Text = .Region
                TextBox8.Text = .PostalCode
                TextBox9.Text = .Country
                TextBox10.Text = .Phone
                TextBox11.Text = .Fax
            End With

        End If
    End Sub

    Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim guardar As New localhost.wsCustomers
        guardar.Escribir(TextBox1.Text,
                         TextBox2.Text,
                         TextBox3.Text,
                         TextBox4.Text,
                         TextBox5.Text,
                         TextBox6.Text,
                         TextBox7.Text,
                         TextBox8.Text,
                         TextBox9.Text,
                         TextBox10.Text,
                         TextBox11.Text,
                         5)
    End Sub
End Class